<template>
	<view class="content">
		<view class="header">
			<view class="left">
				<image :src="$util.prefix('index/logo.png')" class="logo"></image>
				<text class="header_title">安装超圈</text>
				<view :id="is_micromessenger ? 'opacity1' : 'opacity0'">
					<text>点击右上角</text>
					<image :src="$util.prefix('index/h5_more.png')"></image>
				</view>
				<text :id="is_micromessenger ? 'opacity1' : 'opacity0'">选择在浏览器中打开</text>
			</view>
			<view class="right">
				<image :src="$util.prefix('index/h5_to.png')" :id="is_micromessenger ? 'opacity1' : 'opacity0'"></image>
			</view>
		</view>

		<view class="content_image">
			<image :src="$util.prefix('index/h5_bg.png')" mode="widthFix"></image>
		</view>

		<view class="fixed_box">
			<view class="box">
				{{share_code}}
			</view>
			<view class="bottom" @click="onDownLoad">
				复制并下载
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
				ios_url: '',

				// 是否为微信内置浏览器
				is_micromessenger: false,

				share_code: '',
			}
		},
		onLoad(option) {
			this.share_code = option.code;
			this.getDownLoadUrl();
			let ua = navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == "micromessenger") {
				this.is_micromessenger = true;
			} else {
				this.is_micromessenger = false;
			}
		},
		methods: {
			getDownLoadUrl() {
				var that = this;
				this.$post('index/getApkVersion').then(res => {
					that.url = res.data.app_path
					that.ios_url = res.data.ios_path
				})
			},
			copyContent(data) {
				uni.setClipboardData({
					data: this.share_code,
					success: function() {
						uni.getClipboardData({
							success: function(res) {
								uni.showToast({
									title: "复制成功",
									icon: 'none'
								});
							}
						});
					}
				})
			},

			onDownLoad() {
				this.copyContent();
				uni.getSystemInfo({
					success: res => {
						if (res.osName == 'ios') {
							window.open(this.ios_url)
						} else {
							window.open(this.url)
						}
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		height: 100vh;
		padding-bottom: 340rpx;
	}

	#opacity1 {
		opacity: 1;
	}

	#opacity0 {
		opacity: 0;
	}

	.header {
		display: flex;
		align-items: flex-end;
		justify-content: space-between;
		padding: 32rpx 64rpx 0 72rpx;

		.left {
			display: flex;
			flex-direction: column;

			.header_title {
				font-size: 36rpx;
				color: #333333;
				line-height: 50rpx;
				margin-top: 34rpx;
			}

			.logo {
				width: 173.5rpx;
				height: 66rpx;
			}

			view {
				display: flex;
				align-items: center;
				margin: 8rpx 0 8rpx 0;

				image {
					width: 40rpx;
					height: 40rpx;
				}
			}

			text {
				font-size: 28rpx;
				color: #666666;
				line-height: 28rpx;
				margin-right: 8rpx;
			}

		}

		.right {
			width: 90rpx;
			height: 188rpx;

			image {
				width: 90rpx;
				height: 188rpx;
			}
		}
	}

	.content_image {
		margin-top: 46rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;

		image {
			width: 656rpx;
		}
	}

	.fixed_box {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100vw;
		height: 392rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 40rpx 40rpx 0rpx 0rpx;

		.box {
			font-weight: 600;
			font-size: 72rpx;
			color: #131313;
			padding: 80rpx 0 60rpx 0;
			text-align: center;
		}


		.bottom {
			width: 686rpx;
			height: 96rpx;
			background: #FD2A53;
			border-radius: 48rpx;
			font-weight: 600;
			font-size: 28rpx;
			color: #FFFFFF;
			line-height: 96rpx;
			text-align: center;
			margin: 0 auto;
		}

	}

	

</style>